#include <stdio.h>

#define MAXSIZE_N 100000
#define MAXSIZE_M (MAXSIZE_N)


int
main(void)
{
	int n, m, first_sequence[MAXSIZE_N], second_sequence[MAXSIZE_M];
	int i = 0, j;
	freopen("merge.in", "rt", stdin);
	freopen("merge.out", "w", stdout);

	scanf("%d", &n);
	while (i<n)
		scanf("%d", &first_sequence[i++]);
	i = 0;
	scanf("%d", &m);
	while (i<m)
		scanf("%d", &second_sequence[i++]);

	i = j = 0;
	while (i < n || j < m) {
		if (first_sequence[i] > second_sequence[j]) {
			if (j < m)
				printf("%d ", second_sequence[j++]);
			else if (i < n)
				printf("%d ", first_sequence[i++]);
			else
				break;
		} else if (first_sequence[i] <= second_sequence[j]) {
			if (i < n)
				printf("%d ", first_sequence[i++]);
			else if (j < m)
				printf("%d ", second_sequence[j++]);
			else
				break;
		}
	}
	putchar('\n');
	return 0;
}
